package cn.itcast.demo;

import cn.itcast.demo.impl.Temp;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

public class TestTemp {
    public static void main(String[] args) {
        //创建被代理对象
        Temp temp = new Temp();


        //接口名1参数2,参数
      TempFace tempFace  =(TempFace) Proxy.newProxyInstance(temp.getClass().getClassLoader(),
              temp.getClass().getInterfaces(), new InvocationHandler() {
                  @Override
                  public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                      System.out.println("1111111111");
                      //if ("print".equals(method.getName()))
                          method.invoke(temp, args);
                          System.out.println("3333333333");
                          return null;

                      }

              });
         tempFace.print();



    }
}